#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
    printf("before pid=%d ppid=%d\n",getpid(),getppid());
    pid_t id=fork();
    if(id==0)
    {
       printf("I am a child process pid=%d ppid=%d\n",getpid(),getppid());
       sleep(3);
       execl("/usr/bin/ls","ls","-a","-l",NULL);
       exit(0);
    }
    pid_t ret=waitpid(id,NULL,0);
    if(ret==id)
    {
        printf("wait success father pid=%d child pid=%d\n",getpid(),ret);
    }
    sleep(3);
    return 0;
}
